home *** CD-ROM | disk | FTP | other *** search
- defint a-z
- tv$=chr$(255)
- nl$=chr$(0)
- t$=" "
- bf$=space$(512)
- on error goto err.rtn
-
- 1
- open "com1:9600,n,8,1,rs,cs,ds,cd" as #1
-
- begin:
- cls
- locate 5,20
- print "QRECV - Asynchronous file transfer utility"
- locate 10,10
- print "Waiting . . ."
-
- get.char:
- if loc(1)=0 then _
- if inkey$="" then _
- goto get.char _
- else _
- close _
- :cls _
- :end
- mid$(t$,1,1)=input$(1,#1)
- if bm=0 then _
- if t$<>tv$ then _
- print t$; _
- :goto get.char _
- else _
- bm=1 _
- :c=0 _
- :bl=3 _
- :goto get.char
- c=c + 1
- mid$(bf$,c,1)=t$
- cb=cb + asc(t$)
- cb=cb-int(cb/256)*256
- if c<bl then _
- goto get.char
- if bm=1 then _
- bm=2 _
- :cb$=left$(bf$,1) _
- :bl=cvi(mid$(bf$,2,2)) _
- :c=0 _
- :cb=0 _
- :bc=0 _
- :locate 23,10 _
- :print "Block length";bl _
- :goto get.char
- bm=0
- if cb$ <> left$(mki$(cb),1) then _
- locate 23,10 _
- :print "Resend...";space$(10) _
- :print #1, nl$; _
- :goto get.char
- if fm=0 then _
- fl!=cvs(left$(bf$,4)) _
- :fl$=mid$(bf$,5,bl-4) _
- :gosub open.rtn
- :fm=1 _
- :tl!=0 _
- :locate 10,5 _
- :print "Receiving '";fl$;"', length:";fl!;"bytes,";int(fl!/512)+1;"blocks"
- :print #1, tv$; _
- :goto get.char
- bc=bc+1
- locate 23,40
- print "Block";bc
- for j=1 to bl
- lset b$=mid$(bf$,j,1)
- put #2
- next
- print #1, tv$;
- tl!=tl!+bl
- if tl!<fl! then _
- goto get.char
- fm=0
- close 2
- go to begin
-
- open.rtn:
- open fl$ as #2 len=1
- if lof(2) > 0 then _
- close 2 _
- :kill f$ _
- :goto open.rtn
- field#2, 1 as b$
- return
-
- err.rtn:
- if err=57 then _
- bm=0 _
- :locate 20,5 _
- :print "Communications error - restarting" _
- :close 1 _
- :open "com1:9600,n,8,1,rs,cs,ds,cd" as #1 _
- :print #1, nl$; _
- :for j=1 to 500 _
- :next _
- :locate 20,5 _
- :print space$(40) _
- :resume get.char
- on error goto 0